<template>
  <div>
    <!-- 添加访问记录 -->
    <el-dialog title="欢迎访问" :visible.sync="dialogFormVisible.show" :before-close="handleClose">
    <el-form :model="addForm">
        <!-- <el-form-item label="用户id" :label-width="formLabelWidth" hidden>
        <el-input v-model="this.userId" clearable></el-input>
        </el-form-item> -->
        <el-form-item label="游客姓名" :label-width="formLabelWidth">
        <el-input v-model="addForm.visitRecordTouristName" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="游客电话" :label-width="formLabelWidth">
        <el-input v-model="addForm.visitRecordTouristPhone" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="出行目的地" :label-width="formLabelWidth">
        <el-input v-model="addForm.visitRecordTouristDesination" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="访问时间" :label-width="formLabelWidth" hidden>
        <el-date-picker v-model="addForm.visitRecordTime" type="datetime" size="small" format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss"
    :editable="false" @click="getDate"></el-date-picker>
        </el-form-item>
        <el-form-item label="客服id" :label-width="formLabelWidth">
        <el-input v-model="addForm.serviceStaffId" autocomplete="off"></el-input>
        </el-form-item>
        <el-form-item label="备注信息" :label-width="formLabelWidth">
        <el-input v-model="addForm.visitRecordDesc" autocomplete="off"></el-input>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormVisible = false">取 消</el-button>
        <el-button type="primary" @click="addVisitRecord">确 定</el-button>
    </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props:{
     dialogFormVisible:{
      type:Object,
      default:{}
     }
  },
  data() {
    return {
      addForm:{
        visitRecordTime:""
      }
    }
  },
  methods: {
    getDate(){
      this.addForm.visitRecordTime = new Date()
    },
    addVisitRecord(){
      this.addForm.userId = this.userId;
      this.$axios.post("visit/",this.addForm)
      .then(res=>{
        if(res.data.code==200){
          this.$message.success("添加成功");
          this.dialogFormVisible = false
        }
      })
    },
    handleClose(done) {
      this.$confirm('确认关闭？')
        .then(_ => {
          done();
        })
        .catch(_ => {});
    }
  },
  created(){
    this.userId = JSON.parse(sessionStorage.getItem("userId"))
    this.getDate()
  }
};
</script>